﻿using System;
using System.Collections.Generic;
using System.Text;

namespace QuestLib
{

    public class QuestPlayer
    {

        public uint _Ret;


        public uint Ret()
        {
            return _Ret;
        }


        Dictionary<int, iQuest> _RequestList = new Dictionary<int, iQuest>();

        Dictionary<RESULT, REQUEST> _ResultList = new Dictionary<RESULT, REQUEST>();


        public virtual void AddQuest(iQuest quest)
        {
            _RequestList.Add(quest._ID, quest);

            

            Do(quest);
        }

        public void Do(iQuest eventQuest)
        {
            if (eventQuest.MoveNext() == true)
                return;

            _RequestList.Remove(eventQuest._ID);
        }

        public virtual void OnEvent(int eventType,int param)
        {

            EvetArg a = new EvetArg();
            a._eventType = eventType;
            a._param = param;

            iQuest eventQuest = null;

            foreach (iQuest q in _RequestList.Values)
            {
                if( q.IsWaitEvent(a) == true)
                {
                    eventQuest = q;
                }
                    

                
            }


            if (eventQuest == null)
                return;
            Do(eventQuest);

        }




        //public void OnClickNpc(uint npcID)
        //{
        //    OnEventHandle(EVENT.CLICKNPC, npcID,0);
        //}

        //public void OnGetItem(uint itemID)
        //{
        //    OnEventHandle(EVENT.GETITEM, itemID,0);
        //}


        //public void OnDialog(uint msgID, uint ret)
        //{
        //    OnEventHandle(EVENT.GETITEM, msgID, ret);
        //}

    }
}
